package com.focus.wecenter.pojo;

import org.hibernate.annotations.DynamicInsert;
import org.hibernate.annotations.DynamicUpdate;

import javax.persistence.*;
import java.util.Date;
import java.io.Serializable;
import java.util.Objects;

/**
 * @description  文章评论
 * 
 * @author		Lv Jing
 * @date		2018-1-8 17:23:16
 */
@Entity
@Table(name = "article_comments", schema = "wecenter")
@DynamicUpdate
@DynamicInsert
public class ArticleComment implements Serializable {
	private static final long serialVersionUID = 1L;

	private Integer id;
	/**评论内容*/
	private String content;
	/**添加时间*/
	private Date createTime;
	/**评论用户*/
	private User createUser;
	/**所属文章*/
	private Article article;

    @JoinColumn(name = "article_id")
    @ManyToOne
    public Article getArticle() {
        return article;
    }
    public void setArticle(Article article) {
        this.article = article;
    }
    @JoinColumn(name = "user_id")
    @ManyToOne
    public User getCreateUser() {
        return createUser;
    }
    public void setCreateUser(User createUser) {
        this.createUser = createUser;
    }
    @Id
    @Column(name = "ID")
    @GeneratedValue(strategy = GenerationType.IDENTITY)
	public Integer getId() {
		return id;
	}
	public void setId(Integer id) {
		this.id = id;
	}
	@Basic
    @Column(name = "CONTENT")
	public String getContent() {
		return this.content;
	}
	public void setContent(String content) {
		this.content = content;
	}	
	@Basic
    @Column(name = "CREATE_TIME")
	public Date getCreateTime() {
		return this.createTime;
	}
	public void setCreateTime(Date createTime) {
		this.createTime = createTime;
	}

    @Override
    public boolean equals(Object o) {
        if (this == o) {return true;}
        if (o == null || getClass() != o.getClass()) {return false;}
        ArticleComment that = (ArticleComment) o;
        return Objects.equals(id, that.id);
    }

    @Override
    public int hashCode() {
        return Objects.hash(id);
    }
}